package graph_viewer.factory;

import java.io.IOException;


import graph_viewer.app_exception.*;
import graph_viewer.canvas.*;
import graph_viewer.drawer.*;
import graph_viewer.structure.*;
import graph_viewer.util.*;

public class  Node_Drawer_Factory{	
	public Node_Drawer	 create_node_drawer( Node a_node, Node focus_node ){
		Node_Drawer node_drawer  = new Basic_Node_Drawer( a_node.get_is_labelled() );


		
		if ( a_node.is_leaf() ){
			node_drawer = new Leaf_Node_Drawer( a_node.get_is_labelled() );
			//Debug.println( "Leaf_Node_Drawer is created!", 3 );
		}else if ( a_node.is_leaf_cluster() ){
			if ( a_node.get_is_psuedo()){
				node_drawer	= new Psuedo_Node_Drawer( a_node.get_is_labelled() );
				//Debug.println( "Psuedo_Node_Drawer is created!", 3 );
			}else{
				node_drawer = new Leaf_Cluster_Node_Drawer( a_node.get_is_labelled() );
				//Debug.println( "Leaf_Cluster_Node_Drawer is created!", 3 );
			}
		}else if ( !a_node.get_is_closed() ){
			node_drawer = new Cluster_Drawer( a_node.get_is_labelled() );
			//Debug.println( "Cluster_Drawer is created!", 3 );
		} 

		if ( focus_node != null ){
			if ( focus_node.get_is_psuedo() && a_node == focus_node.get_parent() ){
			//after opened, the psuedo node disappears.
			node_drawer = new Focus_Drawer( a_node.get_is_labelled() );
			//Debug.println( "Focus_Drawer is created for psuedo focus'a parent!", 3 );
			}else if (  focus_node!= null && a_node.get_label().equals( focus_node.get_label() ) ){
				node_drawer = new Focus_Drawer( a_node.get_is_labelled() );
				//Debug.println( "Focus_Drawer is created!", 3 );
			}
		}

		return node_drawer;
	}

}
